package com.fairytask.ui.item
{
	import com.fairytask.engine.components.BaseItem;
	import com.fairytask.engine.components.button.Button;
	import com.fairytask.engine.components.clip.Clip;
	import com.fairytask.engine.components.text.Label;
	import com.fairytask.engine.data.BindManager;
	import com.fairytask.engine.data.Modulator;
	import com.fairytask.engine.define.ResConfig;
	import com.fairytask.engine.define.ViewDefine;
	import com.fairytask.engine.resource.StaticIni;
	import com.jzonl.net.messages.CustomToServerFlag;
	import com.jzonl.net.mgr.NetMgr;
	
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	import flashx.textLayout.events.ModelChange;

	public class GoodItem extends BaseItem
	{
		
		private var goodPic:Clip=new Clip();
		private var goodName:Label=new Label();
		private var goodPrice:Label=new Label();
		private var goodSellBtn:Button=new Button();
		private var goodNumLab:Label=new Label();
		private var numBG       :Clip;
		private var numItem     :InfoItem; 
		private var sureBtn     :Button;
		private var cancelBtn   :Button;
		private var _good       :Object;
		private var _num:int;
		public function GoodItem()
		{
			init();
		}
		private function init():void
		{
			goodSellBtn.addEventListener(MouseEvent.CLICK,onBuyGood)
		}
	
		
		public function setGood(good:Object,type:String):void
		{
			_good=good;
			setGoodNum(good.amount);
			setGoodPic(good.icon);
			setGoodName(good.id);
			setGoodPrice(good.price,type);
		}

		private function setGoodNum(num:int):void
		{
			_num=num;
			if(num==0)
			{
				return;
			}
			else
			{
				goodNumLab.htmlStrByBorder=num+"";
			}
		}
		private function onBuyGood(selltype:int):void
		{
			if(_num==0)
			{
				//NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_SHOPPING_ITEM_BUY,_good.id,1);	
			}
			else
			{
				numBG=new Clip();
				numItem=new InfoItem();
			}
		}
		private function setGoodPic(source:String):void
		{
			goodPic.source=ResConfig.sceneResPath+source+".png";
		}
		private function setGoodName(name:String):void
		{
			goodName.htmlStrByBorder=name;
		}
		private function setGoodPrice(price:int,type:String):void
		{
			goodPrice.htmlStrByBorder=price+type;
		}
		
		private function setGoodSellBtn(type:String):void
		{
				
		}
	
	
		
	}
}